var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
	// 页面入口文件配置
	entry: {
		'entry/index': './src/entry/index',
		'entry/about': './src/entry/about'
	},
	// 入口文件输出配置
	output: {
		path: __dirname + '/public/js/',
		filename: '[name].js'
	},
	module: {
		// 加载器配置
		loaders: [{
			test: /\.jsx$/,
			loader: 'uglify!babel-loader!jsx-loader?harmony'
		}, {
			test: /\.css$/,
			loader: ExtractTextPlugin.extract("style-loader", "css-loader")
		}, {
			test: /\.scss$/,
			loader: "style!css!sass"
		}, {
			test: /\.less$/,
			loader: "style!css!less"
		}]
	},
	'uglify-loader': {
		mangle: false
	},
	externals: {
		'jquery': '$'
	},
	// 其他解决方案配置
	resolve: {
		extensions: ['', '.js', '.jsx', '.css', '.json'],
	},
	// 插件项
	plugins: [
		new webpack.optimize.UglifyJsPlugin({
			compress: {
				warnings: false,
			},
			output: {
				comments: false,
			},
		}),
		new webpack.DllReferencePlugin({
			context: __dirname,
			manifest: require('./manifest.json'),
		}),
		new webpack.optimize.CommonsChunkPlugin("common.js", ["entry/index", "entry/about"]),
		new ExtractTextPlugin("../css/[name].css"),
		new webpack.DefinePlugin({
			'process.env': {
				'NODE_ENV': JSON.stringify('production')
			}
		}),
	]
}